#include <iostream>
#include <cmath>

using namespace std;

double UFL(double b,double L){
    return pow(b,L);
}

double OFL(double b,double U,double p){
    return pow(b,U)*(b-pow(b,1-p));
}

double cardinality(double U,double L,double p){
    return pow(2,p)*(U-L+1)+1;
}

int main(int argc, const char * argv[]) {
    const int b=2,p=3,L=-1,U=1;
    int count=1;
    cout<<"UFL(F)="<<UFL(b,L)<<endl;
    cout<<"OFL(F)="<<OFL(b,U,p)<<endl;
    cout<<"\nThe numbers in F system are:"<<endl;
    cout<<"0.00*2^{0}"<<endl;
    for(int i=L;i<=U;i++){
        for(int j=0;j<=1;j++){
            for(int k=0;k<=1;k++){
                cout<<"1."<<j<<k<<"*2^{"<<i<<"}"<<endl;
                cout<<"-1."<<j<<k<<"*2^{"<<i<<"}"<<endl;
                count=count+2;
            }
        }
    }
    cout<<"The total amount of numbers in F is "<<count<<endl;
    cout<<"The cardinality of F is "<<cardinality(U,L,p)<<endl;
    
    cout<<"\nThe subnormal number in F system are:"<<endl;
    int count_n=0;
    for(int i=0;i<=1;i++){
        for(int j=0;j<=1;j++){
            if(i==0&&j==0){
                continue;
            }
            else{
                cout<<"0."<<i<<j<<"*2^{-1}"<<endl;
                cout<<"-0."<<i<<j<<"*2^{-1}"<<endl;
                count_n=count_n+2;
            }
        }
    }
    cout<<"The total amount of subnormal numbers in F is "<<count_n<<endl;
}
